package de.fh.ka.as.car.routing.map;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;

public class CarMapObject extends MapObject
{
    double orientation;

    /**
     * @return the orientation
     */
    public double getOrientation()
    {
	return orientation;
    }

    /**
     * @param orientation
     *            the orientation to set
     */
    public void setOrientation(double orientation)
    {
	this.orientation = orientation;
    }

    public CarMapObject(Point point, double orientation)
    {
	super(point);
	this.orientation = orientation;
    }

    @Override
    public void draw(Canvas canvas, Paint paint)
    {
	int x = getPoint().x + 10;
	int y = getPoint().y + 10;
	paint.setColor(Color.BLUE);
	Path mPath = new Path();
	mPath.moveTo(x, y - 10); // (0, -50);
	mPath.lineTo(x - 5, y + 10); // (-20, 60);
	mPath.lineTo(x, y + 10); // (0, 50);
	mPath.lineTo(x + 5, y + 10); // (20, 60);
	mPath.close();
	canvas.save();
	canvas.rotate((float) orientation, x, y);
	canvas.drawPath(mPath, paint);
	canvas.restore();
    }
}
